package com.lh.service.impl;

import com.lh.service.StuService;
import com.lh.mapper.StuMapper;
import com.lh.pojo.Stu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: foodie-dev
 * @description:
 * @author: LH
 * @create: 2022-03-24 14:14
 **/
@Service
@Transactional(propagation = Propagation.SUPPORTS)
public class StuServiceImpl implements StuService {

    @Autowired
    private StuMapper stuMapper;

    @Override
    public Stu getStu(int id) {
        return stuMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveStu(Stu stu) {

//        Stu stu1 = stuMapper.selectByPrimaryKey(stu.getId());
//        if (stu1 != null){
//
//        }

        stuMapper.insert(stu);
    }

    @Override
    public void updateStu(Stu stu) {
        stuMapper.updateByPrimaryKey(stu);
    }

    @Override
    public void deleteStu(int id) {
        stuMapper.deleteByPrimaryKey(id);
    }
}
